package mop.exception;

/**
 * Exception class for incorrect resources.
 * 
 * @author	 MOP Team 7
 */
public class IllegalResourceException extends Throwable 
{

	/**
	 * Initializes an IllegalResourceException with the given resource.
	 * 
	 * @param 	resource
	 *  		The resource name.
	 *  
	 * @effect 	Sets the resource name.
	 */
	public IllegalResourceException(String resource)
	{
		this.setResource(resource);	
	}
	
	/**
	 * return a error message that can be used by the gui
	 * 
	 * @return an error message describing the incorrect user
	 */
	public String toString()
	{
		
		StringBuffer sb = new StringBuffer();
		sb.append("The following resource is not a valid one, it probably doesn't exist yet! ");
		
		if(this.resource == null)
			sb.append("NULL");
		else if(this.resource.trim().equals(""))
		{
			sb.append("/emptyString");
		}
		else
		{
			sb.append(this.resource);
		}
		
		return sb.toString();
		
	}
	
	 /**
	  * Sets the resource.
	  * 
	  * @param 	resource
	  * 		The task that's causing a racket.
	  *  
	  * @post 	The resource is set to the given one.
	  * 
	  */
	 private void setResource(String resource) 
	 {

		 this.resource = resource;
	 }
	
	/**
	 * weird java demand
	 */
	private static final long serialVersionUID = 1L;
	
	/**
	 * the user thats causing the problem
	 */
	private String resource;
	
}